<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>
      <button class="lightUp">开灯</button>
      <img
        id="img"
        src="./images/关灯.png"
        alt=""
        style="transform: rotate(180deg)"
      />
      <button class="lightOff">关灯</button>
    </div>
  </body>
  <script>
    const lightUp = document.querySelector(".lightUp");
    const lightOff = document.querySelector(".lightOff");
    lightUp.onclick = function () {
      img.src = "./images/开灯.jpg";
    };
    lightOff.onclick = function () {
      img.src = "./images/关灯.png";
    };
  </script>
</html>
